<script lang="ts" setup>
import { StarOutlined, LikeOutlined, MessageOutlined } from '@ant-design/icons-vue';
import {ref} from "vue";
import {useRequest} from "vue-hooks-plus/es";
import {postBlogGetArticle} from "@/apis/student";

const listData: Record<string, string>[] = [];

for (let i = 0; i < 230; i++) {
  listData.push({
    href: '/7000',
    title: `ant design vue part ${i}`,
    avatar: 'https://joeschmoe.io/api/v1/random',
    description:
        'Ant Design, a design language for background applications, is refined by Ant UED Team.',
    content:
        'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
  });
}

const pagination = {
  onChange: (page: number) => {
    console.log(page);
  },
  pageSize: 12,
  hideOnSinglePage: true
};
const actions: Record<string, any>[] = [
  { icon: StarOutlined, text: '156' },
  { icon: LikeOutlined, text: '156' },
  { icon: MessageOutlined, text: '2' },
];

// 获取文章列表
let articleDataList = ref<any>([])
const { loading } = useRequest(()=> postBlogGetArticle({
  pageNum: 1,
  pageSize: 10,
  type:'recommend '
}),{
  onSuccess:((res) => {
    console.log(res.data.list)
    articleDataList.value = res.data.list
  })
})
</script>

<template>
  <a-card>
    <a-list item-layout="vertical" size="default" :pagination="pagination" :data-source="articleDataList">
<!--      <template #footer>-->
<!--        <div>-->
<!--          <b>ant design vue</b>-->
<!--          footer part-->
<!--        </div>-->
<!--      </template>-->
      <template #renderItem="{ item }">
        <a-list-item :key="item.id">
          <template #actions>
          <span v-for="{ icon, text } in actions" :key="icon">
            <component :is="icon" style="margin-right: 8px" />
            {{ text }}
          </span>
          </template>
          <template #extra>
            <img
                width="272"
                alt="logo"
                :src=item.articleCoverImg
            />
          </template>
          <router-link :to="{path:'/read/',query:{type:'article',id:item.id}}">
            <a-list-item-meta :description="item.articleIntro">
              <template #title>
                <a :href="item.id">{{ item.userId }}</a>
              </template>
              <template #avatar><a-avatar :src="item.id" /></template>
            </a-list-item-meta>
          </router-link>
          {{ item.articleContent }}
        </a-list-item>
      </template>
    </a-list>
  </a-card>

</template>

<style scoped lang="scss">

</style>
